﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class add_table_NoDict : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameColumn(
                name: "SRT_NO",
                table: "MainDataDict",
                newName: "SrtNo");

            migrationBuilder.RenameColumn(
                name: "DATA_DICT_NAME",
                table: "MainDataDict",
                newName: "DataDictName");

            migrationBuilder.RenameColumn(
                name: "DATA_DICT_CODE",
                table: "MainDataDict",
                newName: "DataDictCode");

            migrationBuilder.CreateTable(
                name: "MainNoDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    Codg = table.Column<string>(type: "text", nullable: false),
                    Name = table.Column<string>(type: "text", nullable: false),
                    DefaultFlag = table.Column<bool>(type: "boolean", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainNoDict", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "NoDictRule",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    NoDictRuleType = table.Column<int>(type: "integer", nullable: false),
                    Len = table.Column<int>(type: "integer", nullable: false),
                    DefaultValue = table.Column<string>(type: "text", nullable: true),
                    Srtno = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    NoDictId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_NoDictRule", x => x.Id);
                    table.ForeignKey(
                        name: "FK_NoDictRule_MainNoDict_NoDictId",
                        column: x => x.NoDictId,
                        principalTable: "MainNoDict",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_NoDictRule_NoDictId",
                table: "NoDictRule",
                column: "NoDictId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "NoDictRule");

            migrationBuilder.DropTable(
                name: "MainNoDict");

            migrationBuilder.RenameColumn(
                name: "SrtNo",
                table: "MainDataDict",
                newName: "SRT_NO");

            migrationBuilder.RenameColumn(
                name: "DataDictName",
                table: "MainDataDict",
                newName: "DATA_DICT_NAME");

            migrationBuilder.RenameColumn(
                name: "DataDictCode",
                table: "MainDataDict",
                newName: "DATA_DICT_CODE");
        }
    }
}
